<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.text.*"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>IPL 5 - RED</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="content-language" content="" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<%@ include file="global.jsp"%>
<%
String resposeText = "";
String errorMesg = (String) session.getAttribute("error");
out.println("<script>alert(\\"+errorMesg+"\\)</script>");
if (session.getAttribute("resposeText") != null) {

	if(null != (String)session.getAttribute("resposeText")){ 
		out.println("<script>alert("+(String)session.getAttribute("resposeText")+")</script>");
    }else{
    	out.println("<script>alert(\"No Mesg\")</script>");
    }
	
	if(("Succesfully Submited").equals((String)session.getAttribute("resposeText"))){ 
		out.println("<script>alert(\"Succesfully Submited\")</script>");
    }else if(("User Not Registered").equals((String)session.getAttribute("resposeText"))){
    	out.println("<script>alert(\"User Not Registered\")</script>");
    }else if(("Entry already made").equals((String)session.getAttribute("resposeText"))){
    	out.println("<script>alert(\"Entry already made\")</script>");
    }else if(("Please enter your name").equals((String)session.getAttribute("resposeText"))){
    	out.println("<script>alert(\"Please enter your name\")</script>");
    }else if(("Exception Occurred").equals((String)session.getAttribute("resposeText"))){
    	out.println("<script>alert(\"Exception Occurred\")</script>");
    }else if(("Unauthorized User").equals((String)session.getAttribute("resposeText"))){
    	out.println("<script>alert(\"Unauthorized User\")</script>");
    }else if(("UserName Not Entered").equals((String)session.getAttribute("resposeText"))){
    	out.println("<script>alert(\"UserName Not Entered\")</script>");
    }else{
    	out.println("<script>alert(\\"+errorMesg+"\\)</script>");
    } 
} 
%>
<form  action="/IPL5/updateResults.jsp"  name="match" method = "post">

	<div id="page">
		<div id="header">
			<h1>
				<a href="#">IPL-5 2012</a>
			</h1>
		</div>
		<%@ include file="links.jsp"%>
		<div>
		<%
			String parameter = request.getParameter("matchId");
		    System.out.println("parameter:::"+parameter);
			String matchId = parameter.substring(0,parameter.indexOf("*"));
			System.out.println("matchId:::"+matchId);
			String team1 = null;
			String team2 = null;
			
			if(matchId!=null){
				session.setAttribute("matchId",null);
				session.setAttribute("matchId",matchId);
				System.out.println("matchId:::"+session.getAttribute("matchId"));
				try{
					if (matchId!=null) {
				      matchId = (String) session.getAttribute("matchId");
				      String teams = matchId.substring(matchId.indexOf("@")+1,matchId.length());
				      System.out.println("teams:::"+teams);
				      String shortTeam1 = teams.substring(0,teams.lastIndexOf("|"));
				      System.out.println(teams.lastIndexOf("|"));
				      
				      String shortTeam2 = teams.substring(teams.lastIndexOf("|")+1,teams.length());
				      System.out.println(shortTeam2);
				      if(("RCB").equals(shortTeam1)){
				    	  team1 = "Bangalore Royal Challengers";
				      }
				      if(("RCB").equals(shortTeam2)){
				    	  team2 = "Bangalore Royal Challengers";
				      }
				      
				      
				      if(("CSK").equals(shortTeam1)){
				    	  team1 = "Chennai Super Kings";
				      }
				      if(("CSK").equals(shortTeam2)){
				    	  team2 = "Chennai Super Kings";
				      }
				      
				      if(("DC").equals(shortTeam1)){
				    	  team1 = "Deccan Chargers";
				      }
				      if(("DC").equals(shortTeam2)){
				    	  team2 = "Deccan Chargers";
				      }
				      
				      if(("DD").equals(shortTeam1)){
				    	  team1 = "Delhi DareDevils";
				      }
				      if(("DD").equals(shortTeam2)){
				    	  team2 = "Delhi DareDevils";
				      }
				      
				      if(("KXP").equals(shortTeam1)){
				    	  team1 = "Kings XI Punjab";
				      }
				      if(("KXP").equals(shortTeam2)){
				    	  team2 = "Kings XI Punjab";
				      }
				      
				      if(("KKR").equals(shortTeam1)){
				    	  team1 = "Kolkata Knight Riders";
				      }
				      if(("KKR").equals(shortTeam2)){
				    	  team2 = "Kolkata Knight Riders";
				      }
				      
				      if(("MI").equals(shortTeam1)){
				    	  team1 = "Mumbai Indians";
				      }
				      if(("MI").equals(shortTeam2)){
				    	  team2 = "Mumbai Indians";
				      }
				      
				      if(("RR").equals(shortTeam1)){
				    	  team1 = "Rajasthan Royals";
				      }
				      if(("RR").equals(shortTeam2)){
				    	  team2 = "Rajasthan Royals";
				      }
				      
				      if(("KT").equals(shortTeam1)){
				    	  team1 = "Kochi Team";
				      }
				      if(("KT").equals(shortTeam2)){
				    	  team2 = "Kochi Team";
				      }
				      
				      if(("PW").equals(shortTeam1)){
				    	  team1 = "Pune Warriors";
				      }
				      if(("PW").equals(shortTeam2)){
				    	  team2 = "Pune Warriors";
				      }
				    }
				}catch(Exception e){
					e.printStackTrace();
				}
			}
		%>
		</div>

		<div id="main">
			<div id="content">
			<center>
				<table>
					<tr>
						<td>
							<h2><%=team1%> Vs <%=team2%></h2>
						</td>
					</tr>
				</table>
			</center>
				 <br/>  
				<table style="" border="1" cellspacing="0" cellpadding="0">
					<tr>
						<td align="right"><img src="images\blackCupLogo.png"></td>
						<td>
								<table>
									<tr>
										<td align="right">Winner:</td>
										<td><input type="text" name="resultWinner" /></td>
									</tr>
								</table>
						</td>
					</tr>
					<tr>
						<td align="right"><img width="100%"
							src="images\batsmenLogo.jpg"></td>
						<td>
								<table>
									
									<tr>
										<td align="right">MOM:</td>
										<td><input type="text" name="resultMom" /></td>
									</tr>
								</table>
						</td>
					</tr>
					<tr>
						<td align="right"><img width="100%" src="images\sixer.jpg"></td>
						<td>
								<table>
									<tr>
										<td align="right">Sixers Team:</td>
										<td><input type="text" name="resultSixTeam" /></td>
									</tr>
									<tr>
										<td align="right">Sixes Count:</td>
										<td><input type="text" name="resultSixes" /></td>
									</tr>
								</table>
						
						</td>
						
					</tr>
					<tr>
						
						<td colspan="2">
								<table>
									<tr>
										<td><input type="checkbox" name="General" /></td> 
										<td>General</td>
									</tr>
									<tr>
										<td><input type="checkbox" name="MCC" /></td> 
										<td>MCC</td>
									</tr>
									<tr>
										<td><input type="checkbox" name="Office" /></td> 
										<td>Office</td>
									</tr>
									<tr>
										<td><input type="checkbox" name="RVA" /></td> 
										<td>RVA</td>
									</tr>
								</table>
						
						</td>
					
					</tr>
					<tr>
						<td COLSPAN="2" align="center">
							<input type="submit" value="Submit" size="7" /> <input type="reset"	value="Reset" size="7" />
						</td>
					</tr>
				</table>
			</div>
			<!-- content -->

			<div class="clearing">&nbsp;</div>
		</div>
		<!-- main -->
	</div>
	<!-- page -->
	<div id="footer">
		<p>
			Copyright &copy; 2010, designed by <a
				href="http://www.kiranvenkat.in/">kiranvenkat.in</a>
		</p>
	</div>
</form>
</body>
</html>
<%
   if ( session.getAttribute("resposeText") != null && !("").equals(session.getAttribute("resposeText")))
   { 
		session.setAttribute("resposeText", null);
   }
%>